//
//  MRNetManager.m
//  MReader
//
//  Created by Qi Liu on 2020/4/2.
//  Copyright © 2020 Qi Liu. All rights reserved.
//

#import "BLNetManager.h"

@implementation BLNetManager

+ (instancetype)sharedHttpManager {
    static BLNetManager *instance;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[self alloc] init];
        instance = [[BLNetManager alloc] initWithBaseURL:[NSURL URLWithString:BL_BASEURL]];
        instance.requestSerializer = [AFHTTPRequestSerializer serializer];
        instance.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/plain",@"text/html", nil];
        instance.requestSerializer.timeoutInterval = 20;
        instance.requestSerializer.HTTPShouldHandleCookies = YES;
    });
   
    
    return instance;
}

-(NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(id)parameters progress:(void (^)(NSProgress * _Nonnull))downloadProgress success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure{
  return  [super GET:URLString parameters:parameters progress:downloadProgress success:success failure:failure];
}


-(NSURLSessionDataTask *)POST:(NSString *)URLString parameters:(id)parameters progress:(void (^)(NSProgress * _Nonnull))uploadProgress success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure{
    return [super POST:URLString parameters:parameters progress:uploadProgress success:success failure:failure];
}


@end
